﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace ProjectThuCung.Models
{

    public enum SubLoaiSP
    {
        ThuCung,
        ThucAn,
        Thuoc,
        Chuong, 
        DoChoi
    }

    public class LoaiSanPham
    {
        [Key]
        public int LoaiSanPhamID { get; set; }

        [Required]
        [MaxLength(56)]
        [Display(Name = "Loại")]
        public String TenLoaiSanPham { get; set; }

        [Required]
        [MaxLength(3000)]
        [Display(Name = "Sơ lược")]
        public String ThuocTinh { get; set; }

        [Required]
        [Display(Name = "Phân loại chi tiết")]
        public SubLoaiSP SubLoaiSanPham { get; set; }

        public virtual ICollection<SanPham> SanPhams { get; set; }

        public static List<LoaiSanPham> loaisanpham = LoaiSanPham.load_lsp();

        static List<LoaiSanPham> load_lsp()
        {
            ThuCungDB db = new ThuCungDB();
            var data = db.LoaiSanPhams.ToList();
            if (data.Count > 0)
            {
                return data;
            }
            return null;
        }
    }
}